home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 August (Alt) / CHIP 2005-08.1.iso / program / guvenlik / syslinux-3.07.exe / com32 / lib / pci / readx.c < prev    next >
Encoding:
C/C++ Source or Header  |  2005-01-05  |  823 b   |  49 lines

  1. #include "pci/pci.h"
  2.  
  3. TYPE BWL(pci_read) (pciaddr_t a)
  4. {
  5.   TYPE r;
  6.  
  7.   for (;;) {
  8.     switch ( __pci_cfg_type ) {
  9.     case PCI_CFG_AUTO:
  10.       pci_set_config_type(PCI_CFG_AUTO);
  11.       break;            /* Try again */
  12.       
  13.     case PCI_CFG_TYPE1:
  14.       {
  15.     uint32_t oldcf8;
  16.     cli();
  17.     oldcf8 = inl(0xcf8);
  18.     outl(a, 0xcf8);
  19.     r = BWL(in) (0xcfc + (a & 3));
  20.     outl(oldcf8, 0xcf8);
  21.     sti();
  22.       }
  23.       return r;
  24.       
  25.     case PCI_CFG_TYPE2:
  26.       {
  27.     uint8_t oldcf8, oldcfa;
  28.     
  29.     if ( a & (0x10 << 11) )
  30.       return (TYPE)~0;
  31.     
  32.     cli();
  33.     oldcf8 = inb(0xcf8);
  34.     oldcfa = inb(0xcfa);
  35.     outb(0xf0 + ((a >> (8-1)) & 0x0e), 0xcf8);
  36.     outb(a >> 16, 0xcfa);
  37.     r = BWL(in) (0xc000 + ((a >> (11-8)) & 0xf00) + (a & 0xff));
  38.     outb(oldcf8, 0xcf8);
  39.     outb(oldcfa, 0xcfa);
  40.     sti();
  41.       }
  42.       return r;
  43.       
  44.     default:
  45.       return (TYPE)~0;
  46.     }
  47.   }
  48. }
  49.